package cn.xeblog.xechat.controller;

import cn.xeblog.xechat.domain.vo.ResponseVO;
import cn.xeblog.xechat.service.UploadService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 上传文件
 *
 * @author yanpanyi
 * @date 2019/03/27
 */
@RestController
@Slf4j
public class LoginController {
    @Value("${login.userList}")
    private String userList;

    /**
     * 登陆
     *
     * @param userName
     * @return
     * @throws Exception
     */
    @PostMapping("/login")
    public ResponseVO login(@RequestParam("userName") String userName) throws Exception {
        log.info("userName: "+ userName);
        log.info("userList: "+ userList);
        String[] users = userList.split(",");
        boolean success = false;
        for(String user:users){
            if(user.equals(userName)){
                success = true;
                break;
            }
        }
        return new ResponseVO(success);
    }
}
